<template>
	<view class="content page">
		<status-bar title='地址管理'></status-bar>
		<view  class="list">
			<view class="addr_list" v-if='addList'>
				<view class="addr_item flex-box align-center" v-for='(item,index) in addList' :key='index'>
					<view class="addr_info flex" @click='chooseAdd(item.id)'>
						<view class="addr_info_h">
							<text class="addr_info_name">{{item.Aname}}</text><text style="margin-left: 5px;" class="addr_info_phone">{{item.Amobile}}</text>
						</view>
						<view class="addr_info_c">{{item.Aregion}}{{item.Aaddress}}</view>
					</view>
					<navigator :url="'/orderPage/order/addAddress?page_type=3&editId='+item.id" hover-class="none">
						<text class="iconfont icon-tubiao09"></text>
					</navigator>
				</view>
			</view>
			<empty v-else type='1' cat='4' msg='你还没有收货地址哦 <br>赶快添加地址开始买买买吧~'></empty>
			<view class="addr_pop_ftr">
				<navigator url="/orderPage/order/addAddress?page_type=3" hover-class="none">
					<view class="btn4 choose_wxaddr thmeBg" :style="{'--color': color}">添加地址</view>
				</navigator>
			</view>
		</view>
	</view>
</template>

<script>
	var that;
	export default{
		data(){
			return{
				
				color: getApp().globalData.color,
				adId:'',
				addList:'',
			}
		},
		onShareAppMessage(option) {
			let shareData = uni.getStorageSync('shareData');	
			let vid = uni.getStorageSync('vid');
			return {
				title: shareData.title,
				desc: shareData.desc,
				path: '/pages/index/index?share_v_id=' + vid,
				imageUrl: shareData.imageUrl
			}
		},
		onShow(){
			that = this
			that.getAdress()
		},
		onLoad() {
			// #ifdef H5
			this.H5Share()
			// #endif
		},
		methods:{
			chooseAdd(id){// 选择收货地址
				that.adId = id;
				that.getCurrAdd(id);
			},
			getCurrAdd(id){ //获取选择的地址
				that.$http.post({
					url: '/zzj_singleSaleApi/obtainAddress',
					data: {
						id: id,
					}
				}).then(res => {
					if(res.data)
						that.addDetail = res.data
				})
			},
			getAdress(){ // 获取收货地址
				that.$http.post({
					url: '/zzj_singleSaleApi/getAddress',
					data: {
						v_id: uni.getStorageSync("vid"),
					}
				}).then(res => {
					if(res.data)
						that.addList = res.data
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.page{
		.list{
			background: #ffffff;
			padding-bottom: 148rpx;
			.addr_list{
				overflow-x: hidden;
				-webkit-overflow-scrolling: touch;
				.addr_item{
					height: 157upx;
					border-bottom: 1px solid #dddddd;
					padding: 0 30upx;
					position: relative;
					.addr_info_c{
						overflow: hidden;
						text-overflow: ellipsis;
						color: #666666;
					}
					.addr_info_h{
						overflow: hidden;
						text-overflow: ellipsis;
						margin-bottom: 15upx;
						font-size: 36upx;
						font-family: arial;
					}
				}
			}
		}
	}
	.addr_pop_ftr{
		padding: 30upx 0;
		background: #ffffff;
		position: fixed!important;
		left: 0;
		bottom: 0;
		width: 100%;
		z-index: 33;
		margin-bottom: constant(safe-area-inset-bottom);
		margin-bottom: env(safe-area-inset-bottom);
	}
</style>
